package com.etc.test;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.etc.entity.Medicine;
import com.etc.service.MedicineService;
import com.github.pagehelper.PageInfo;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext.xml", "classpath:mybatis-config.xml" })
public class MedicineTestJUnit {

	@Autowired
	private MedicineService medicineService;
	
	
	/**
	 * 查询所有药品测试
	 */
	@Test
	public void selectMedicine() {
		List<Medicine> medicine = medicineService.selectMedicineByPage(11,10);
		medicine.forEach(System.out::println);
	}
	
	/**
	 * 添加药品测试
	 */
	@Test
	public void addMedicine() {
		Medicine medicine = new Medicine("阿莫西林", "消炎药",10, 10.);
		System.out.println(medicineService.insertMedicine(medicine));
	}
	
	/**
	 * 修改药品信息测试
	 */
	@Test
	public void updMedicine() {
		Medicine medicine = new Medicine("胃炎康胶囊胶囊", "胃药",10, 19,13);
		System.out.println(medicineService.updMedicine(medicine));
	}
	
	/**
	 * 删除药品测试
	 */
	@Test
	public void delMedicine() {
		System.out.println(medicineService.delMedicine(2));
	}
	
	
	/**
	 * 查询所有药品数量
	 */
	@Test
	public void selCountMedicine() {
		System.out.println(medicineService.selCountMedicine());
	}
	/**
	 * 查询所有药品类型
	 */
	@Test
	public void selMedicineType(){
		List<Medicine> list = medicineService.selMedicineType();
		list.forEach(System.out::println);
	}
	/**
	 * 根据类型查询所有药品
	 */
	@Test
	public void selMedicineByType(){
		List<Medicine> list = medicineService.selMedicineByType("胃药");
		list.forEach(System.out::println);
	}
	
}
